Ext.define('App.kpiconfiguration.view.KpiConfigurationSelectionWindow', {
    extend: 'Ext.window.Window',
    alias: 'widget.KpiConfigurationSelectionWindow',
    requires: ['App.datasource.view.TableFieldSelection'],
    modal: true,
    title: '数据源选择',
    layout: 'border',
    items: [{
        xtype: 'tabpanel',
        columnWidth: 1,
        region: 'center',
        items: []
    }],
    initComponent: function () {
        var me = this;
        me.callParent(arguments);
        Ext.Ajax.request({
            url: 'data_table/query_only',
            success: function (resp) {
                var ite = [];
                var data = resp.result.data;
                for (var i = 0; i < data.length; i++) {
                    var item = {
                        xtype: 'TableFieldSelection',
                        extraParams: {'params.dataTable.id_eq': data[i].id, "params.id_notin": me.ids},
                        title: data[i].alias,
                        listeners: {
                            beforeload: function () {
                                this.getStore().getProxy().setUrl('table_field/query_sample')
                            },
                            rowdblclick: function ($this, record, element, rowIndex, e, eOpts) {
                                this.up('window').fireEvent('selected', [record]);
                                this.up('KpiConfigurationSelectionWindow').close();
                            }
                        }
                    };
                    ite.push(item);
                }
                me.down('tabpanel').add(ite);
            }
        })
    }
});